Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unist-util-position

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unist-util-position

Utility to get the position of unist nodes

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is unist-util-position?

The unist-util-position package is a utility for working with positional information in unist syntax trees. It provides functions to get and manipulate positions of nodes within these trees, which is useful for tasks such as error reporting, syntax highlighting, and more.

What are unist-util-position's main functionalities?

position.start

This feature retrieves the starting position of a node. The code sample demonstrates how to use the `position.start` function to get the starting line and column of a node.

const position = require('unist-util-position');
const node = { position: { start: { line: 1, column: 1 }, end: { line: 1, column: 5 } } };
console.log(position.start(node)); // { line: 1, column: 1 }

position.end

This feature retrieves the ending position of a node. The code sample shows how to use the `position.end` function to get the ending line and column of a node.

const position = require('unist-util-position');
const node = { position: { start: { line: 1, column: 1 }, end: { line: 1, column: 5 } } };
console.log(position.end(node)); // { line: 1, column: 5 }

position.point

This feature normalizes a point object. The code sample demonstrates how to use the `position.point` function to ensure a point object has the correct structure.

const position = require('unist-util-position');
const point = { line: 1, column: 1 };
console.log(position.point(point)); // { line: 1, column: 1 }

Other packages similar to unist-util-position

Keywords

FAQs

Package last updated on 13 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc